package com.chenpeijian.demo.demos.web.controller;

import com.chenpeijian.demo.demos.web.vo.UserRequest;
import com.chenpeijian.demo.demos.web.vo.group.RegisterGroup;
import com.chenpeijian.demo.demos.web.vo.group.UpdateGroup;
import com.chenpeijian.demo.service.dto.UserRegistrationRequest;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @program: student_code
 * @description: 校验验证
 * @author: 陈培建
 * @create: 2024-12-12 17:13
 **/
@RestController
@RequestMapping("/validator")
@Tag(name="校验验证")
public class ValidatorController {
    /** 
    * @Description: 根据分组定义不同的校验规则
    * @Param: [request]
    * @return: org.springframework.http.ResponseEntity<java.lang.String>
    * @Author: 陈培建
    * @Date: 2024/12/12
    */
    @Operation(summary="注册")
    @PostMapping("/register")
    public ResponseEntity<String> register(@Validated(RegisterGroup.class) @RequestBody UserRequest request) {
        return ResponseEntity.ok("注册成功！");
    }
    @Operation(summary="更新")
    @PutMapping("/update")
    public ResponseEntity<String> update(@Validated(UpdateGroup.class) @RequestBody UserRequest request) {
        return ResponseEntity.ok("更新成功！");
    }
}
